import java.util.AbstractList;
import java.util.List;

public class ListAdapter {

	public static List<Integer> asList(final int[] a) {
		return new AbstractList<Integer>() {
			public Integer get(int i) {
				return a[i];
			}

			// Not working if val == null
			public Integer set(int i, Integer val) {
				Integer oldVal = a[i];
				a[i] = val;
				return oldVal;
			}

			public int size() {
				return a.length;
			}
		};
	}

	public static void main(String[] args) {
		int[] arr = { 1, 2, 3, 4, 5, 6, 7 };
		List<Integer> list = ListAdapter.asList(arr);
		System.out.println(list.get(3));
		list.set(3, 21);
		System.out.println(list);
	}

}
